# -*- coding: utf-8 -*-
from langchain_elasticsearch import ElasticsearchStore

from configs import ES_KB_INDEX_NAME, ES_CLAUSE_INDEX_NAME, ES_URL, ES_PASSWORD, ES_USER, ES_KB_EMERGENCY_NAME
from service.embeddings import embeddings

from .es_conn import ESConnection
from .es_operate import add_documents_to_es, ik_match_search, similarity_search_with_score
from loguru import logger


kb_vector_store = ElasticsearchStore(
    ES_KB_INDEX_NAME, embedding=embeddings, es_url=ES_URL, es_user=ES_USER, es_password=ES_PASSWORD
)
logger.info(f"连接es: {ES_URL}:{ES_KB_INDEX_NAME}")

kb_vector_store_emergency = ElasticsearchStore(
    ES_KB_EMERGENCY_NAME, embedding=embeddings, es_url=ES_URL, es_user=ES_USER, es_password=ES_PASSWORD
)

logger.info(f"连接es: {ES_URL}:{ES_KB_EMERGENCY_NAME}")

clause_vector_store = ElasticsearchStore(
    ES_CLAUSE_INDEX_NAME, embedding=embeddings, es_url=ES_URL, es_user=ES_USER, es_password=ES_PASSWORD
)


ELASTICSEARCH = ESConnection()
ELASTICSEARCH.conn(client=kb_vector_store.client)

ELASTICSEARCH_EMERGENCY = ESConnection()
ELASTICSEARCH_EMERGENCY.conn(client=kb_vector_store_emergency.client)
# ELASTICSEARCH 用来关键词检索
# kb_vector_store 用来向量检索、入库
